<?php echo link_to('жагсаалт', 'content/index', array('class'=>'title'))?> 
<span class="separator"> | </span>
<?php echo link_to('шинээр нэмэх', 'content/new', array('class'=>'title'))?>
<br clear="all">
<br clear="all">


<form action="<?php echo url_for('content/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="POST" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>

<table width="100%">
  <tfoot>
    <tr>
      <td colspan="2">
        <?php echo $form->renderHiddenFields(false) ?>
        <a href="<?php echo url_for('content/index') ?>">Back to list</a>&nbsp;
        <input type="submit" value="Save"/>
      </td>
    </tr>
  </tfoot>
  <tbody>
    <?php echo $form->renderGlobalErrors() ?>
    <tr>
      <th><?php echo $form['season_id']->renderLabel() ?></th>
      <td>
        <?php echo $form['season_id']->renderError() ?>
        <?php echo $form['season_id'] ?><br>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['object_type']->renderLabel() ?></th>
      <td>
        <?php echo $form['object_type']->renderError() ?>
        <?php echo $form['object_type'] ?><br>
        <div id="container_object_id">&nbsp;</div>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['category_id']->renderLabel() ?></th>
      <td>
        <?php echo $form['category_id']->renderError() ?>
        <?php echo $form['category_id'] ?>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['title']->renderLabel() ?></th>
      <td>
        <?php echo $form['title']->renderError() ?>
        <?php echo $form['title'] ?>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['image']->renderLabel() ?></th>
      <td>
        <?php echo $form['image']->renderError() ?>
        <?php echo $form['image'] ?>
        <span class="description"><?php echo $form['image']->renderHelp() ?></span>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['intro']->renderLabel() ?></th>
      <td>
        <?php echo $form['intro']->renderError() ?>
        <?php echo $form['intro'] ?>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['content']->renderLabel() ?></th>
      <td>
        <?php echo $form['content']->renderError() ?>
        <?php echo $form['content'] ?>
      </td>
    </tr>
    <tr>
      <th><?php echo $form['sort']->renderLabel() ?></th>
      <td>
        <?php echo $form['sort']->renderError() ?>
        <?php echo $form['sort'] ?>
      </td>
    </tr>
  </tbody>
</table>

</form>

<script type="text/javascript">
function loadObjects()
{
  $.ajax({
      url: "<?php echo url_for('content/loadObjects')?>",
      data: {seasonId : $('#news_season_id').val(), objectType : $('#news_object_type').val(), objectId: <?php echo $sf_request->getParameter('objectId') ? $sf_request->getParameter('objectId') : 0?>},
      type: "POST",
      success: function(data){
          $('#container_object_id').html('<select id="news_object_id" name="news[object_id]" style="width:400px;">' + data + '</select>');
      }
  });
  return false;
}

$(document).ready(function() {
    loadObjects();  
});
</script>